<template>
	<view>
		<view class="cu-custom"  :style="[{height:CustomBar + 'px'}]">
			<view class="cu-bar fixed" style="min-height: 150rpx;" :style="style" :class="[bgImage!=''?'none-bg text-white bg-img':'',bgColor,goodpoor=='true'?'text-ablack':'',shop=='true'?'text-newblack':'',]">
				<view class="action" @tap="BackPage" v-if="isBack">
					<text style="color: #fff;" class="cuIcon-back"></text>
					<slot name="backText"></slot>
				</view>
				<view class="action" @tap="backbackpack" v-if="iscase">
					<text style="color: #fff;" class="cuIcon-back"></text>
					<slot name="backText"></slot>
				</view>
				<view class="content" style="width: 100%;" :style="[{top:StatusBar + 'px'}]" v-if="!goodpoor">
					<slot name="content"></slot>
				</view>
				<view class="action" style="position: absolute;right: 0%;top: 10%;" v-if="goodpoor">
					<text class='cuIcon-presentfill' @click="backbackpack()"></text>
				</view>
				<slot name="right"></slot>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				StatusBar: this.StatusBar,
				CustomBar: this.CustomBar
			};
		},
		name: 'cu-custom',
		computed: {
			style() {
				var StatusBar= this.StatusBar;
				var CustomBar= this.CustomBar;
				var bgImage = this.bgImage;
				var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
				if (this.bgImage) {
					style = `${style}background-image:url(${bgImage});`;
				}
				return style
			}
		},
		props: {
			bgColor: {
				type: String,
				default: ''
			},
			isBack: {
				type: [Boolean, String],
				default: false
			},
			goodpoor: {
				type: [Boolean, String],
				default: false
			},
			shop: {
				type: [Boolean, String],
				default: false
			},
			bgImage: {
				type: String,
				default: ''
			},
			iscase: {
				type: [Boolean, String],
				default: false
			},
		},
		methods: {
			BackPage() {
				var _this = this;
				uni.navigateBack({
					delta: 1,
					success: function() {
					},
					fail:function() {
						_this.BackTop();
					},
				});
			},
			BackTop(){
				/*uni.switchTab({
					url: `/pages/index/home`
				});*/
				uni.navigateTo({
					url: `/pages/index/index`
				});
			},
			backbackpack(){
				uni.reLaunch({
					url: `/pages/index/index?mes=backpack`
				});
			},
		}
	}
</script>

<style>

</style>
